import time
import requests
import json

# 增量爬虫

url = "https://api.bilibili.com/x/web-interface/newlist_rank"
params = {
    'main_ver': 'v3',
    'search_type': 'video',
    'view_type': 'hot_rank',
    'copy_right': '-1',
    'new_web_tag': '1',
    'order': 'click',
    'cate_id': '247',
    'page': 1,
    'pagesize': '30',
    'time_from': '20240901',
    'time_to': '20241001'
}
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
}
response = requests.get(url, params=params, headers=headers)
result = response.content.decode()
print(response.status_code, result)
result = json.loads(result)
print("视频总数：", result["data"]["numResults"])
